//2016/1/29 星期五	打印数据表
$(document).on("click",".toNetHref",function(){
		var url = $(this).attr("_url");
		var row = $(this).attr("_row");
		var pos = $(this).attr("_pos");//指定 li/tr 类别
		//统计点击次数			实时数据，不采用本地存储方式
		$.post(H.APP+'admin/admin.php',{item:"toHrefCount",row:row,model:"internet",uid:Math.random()},
			function(data){
				$("#"+pos+row).html(data);
				console.log("数据点击量为："+data);
		});
		window.open(url,"_blank");
});
//console.log(H.getStorage("internet"));
//full 是否选择全显示(true,是)
function tableInternet(full)
{
	var internet = H.getStorage("internet");
	if(H.empty(internet)){
		if(!setDataloSt())
			return;
	}
	full = (H.empty(full)? true : full);
	var html = '<table class="interTb"><tr><th>序号</th><th>名称</th><th>网址</th>'+((full == true)? '<th>是否注册</th><th>注册账号</th><th>用户口令</th><th>绑定邮箱</th><th>绑定手机</th>' : '')+'<th>备注</th><th>编辑时间</th><th>编辑IP</th></tr>';
	var exsafe = "",uersSafe = "unsafe",psswSafe = "unSafe",emailSafe = "unSafe",cellSafe = "unSafe";
	var obj = $.parseJSON(internet);
	for(var k in obj)
	{
		if(obj[k][2] == "是"){
			exsafe = '<input type="checkbox" class="exsafe" id="ckbox-'+k+'"  value="'+k+'">';
			if(obj[k][3] != "~" && obj[k][3] != ""){
					uersSafe = "uersSafe-"+k;
			}
			if(obj[k][3] != "~" && obj[k][4] != ""){
					psswSafe = "psswSafe-"+k;
			}
			if(obj[k][3] != "~" && obj[k][5] != ""){
					emailSafe = "emailSafe-"+k;
			}
			if(obj[k][3] != "~" && obj[k][6] != ""){
					cellSafe = "cellSafe-"+k;
			}
			
		}else{
			exsafe = "否";
		}
		html += '<tr  id="dataTr:'+obj[k]["dataRow"]+'"><td>'+(parseInt(k)+1)+" "+((full == true && !H.empty(obj[k][10]))? '<a href="javascript:void(0);" class="disExplanA" _cont="'+obj[k][10]+'"><img src="'+H.IMG+'glyphicons_345_hand_right.png"></a>' : "")+'</td><td><sup id="dataTr'+obj[k]["dataRow"]+'">'+obj[k][11]+'</sup><a href="javascript:void(0);" _url="'+obj[k][1]+'" class="toNetHref" _row="'+obj[k]["dataRow"]+'" _pos="dataTr">'+obj[k][0]+'</a></td><td><div class="tbDec_site">'+obj[k][1]+'</div></td>'+((full == true)? ('<td>'+exsafe+'</td><td id="'+uersSafe+'"><div class="tbDec_username">'+obj[k][3]+'</div></td><td id="'+psswSafe+'"><div class="tbDec_passw">'+obj[k][4]+'</div><td id="'+emailSafe+'"><div class="tbDec_email">'+obj[k][5]+'</div></td><td id="'+cellSafe+'"><div class="tbDec_cellphone">'+obj[k][6]+'</div></td>') : '')+'<td><div class="tbDec_remark">'+obj[k][7]+'</div></td><td>'+obj[k][8]+'</td><td>'+obj[k][9]+'</td></tr>';
	}
	//console.log(obj);
	//console.log(internet);
	return html;
}

function ulsInternet()
{
	var internet = H.getStorage("internet");
	if(H.empty(internet)){
		if(!setDataloSt())
			return;
	}
	var html = '<ul id="ulsInternet">';
	var obj = $.parseJSON(internet);//Firefox 报错 parseJSON,	IE 正常
	for(var k in obj)
	{
		html += '<li id="dataLi:'+obj[k]["dataRow"]+'"><sup id="dataLi'+obj[k]["dataRow"]+'">'+obj[k][11]+'</sup><a href="javascript:void(0);" _url="'+obj[k][1]+'"  _row="'+obj[k]["dataRow"]+'" class="toNetHref" _pos="dataLi">'+obj[k][0]+' ('+obj[k][7]+') <i>'+obj[k][8]+'</i>#'+obj[k][9]+'</a></li>';
	}
	return html+"</ul>";
}
//把数据库值提取到 本地存储
function setDataloSt()
{
	var internet = H.getStorage("internet");
	if(H.empty(internet)){
		$.post(H.APP+'admin/admin.php',{item:"ajaxLoad",model:"internet",uid:Math.random()},
			function(data){
				if(H.empty(data)){
					alert("从后台获取数据失败！！");
					return false;
				}
				H.setStorage("internet",data);
		});
	}
}